package the.guanzhong.express.infrastructure.common.enums;

import lombok.Getter;

import java.util.Arrays;

/**
 * 订单状态
 */
public enum OrderStatusEnum {
    PRE_PAY(10, "预订单"),
    WAITING_PAY(20, "待付款"),
    WAITING_RECEIVE(30, "待接单"),
    RECEIVED(40, "已接单"),
    TOOK(45, "已取件"),
    HAULAGE(50, "已发货"),
    COMPLETED(90, "已完成"),
    REFUND(91, "售后退款");

    @Getter
    private Integer code;

    @Getter
    private String name;

    OrderStatusEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public static String getNameByCode(Integer code) {
        return Arrays.stream(OrderStatusEnum.values()).filter(it -> it.getCode() == code).findFirst().get().getName();
    }
}
